#Вариант, когда на вход подается любое количество слов.
english_to_digit = {
    "zero": 0,
    "one": 1,
    "two": 2,
    "three": 3,
    "four": 4,
    "five": 5,
    "six": 6,
    "seven": 7,
    "eight": 8,
    "nine": 9
}

def is_prime(num):
    if num < 2:
        return False
    for i in range(2, int(num**0.5) + 1):
        if num % i == 0:
            return False
    return True


#проверка ввода
def process_input(words):
    digits = []

    #проверка неправильности ввода
    for word in words:
        if word not in english_to_digit:
            return "Wrong input"
        digits.append(str(english_to_digit[word]))


    number = int(''.join(digits))

    if number < 100 or number > 999:
        return "Wrong input"

    lower = number
    upper = number


    while True:
        if is_prime(lower):
            return lower
        if is_prime(upper):
            return upper
        lower -= 1
        upper += 1

#ввод и проверка
inpu = input()
words = inpu.lower().split()
print(process_input(words))




'''
#второй вариант, с добавленной проверкой ввода двух слов.
def process_input_v2(words):
    digits = []

    for word in words:
        if word.isdigit():
            digits.append(word)
        elif word in english_to_digit:
            digits.append(str(english_to_digit[word]))
        else:
            return "Wrong input"
        
    number = int(''.join(digits))
    lower = number
    upper = number

    while True:
        if is_prime(lower):
            return lower
        if is_prime(upper):
            return upper
        lower -= 1
        upper += 1

user_input = input()
words = user_input.lower().split()
print(process_input_v2(words))
'''

